<?php
    // edit bible verse

    if (!defined("EXPONENT")) exit("");
    $verse = null;
    if (exponent_users_isAdmin() &&  isset($_REQUEST['book']) && isset($_REQUEST['chapter']) && isset($_REQUEST['translation']) && isset($_REQUEST['verse']))
    {
        $translation = intval($_REQUEST['translation']);
        // get translation short name
        $bible=$db->selectObject("bibles","id = " . $translation);
        if ($bible == null) 
        {
            die();
        }
        else
        {
            $short_name = $bible->short_name;
            $book=intval($_REQUEST['book']); $chapter=intval($_REQUEST['chapter']);
            $verse=intval($_REQUEST['verse']);

            $data=$db->selectObject("bible_".$short_name,"book = {$book} AND chapter = {$chapter} AND verse = {$verse}");
            if (!$data)
            {
                echo SITE_404_HTML;
                die();
            }
            
            $form = bible::form($data, $translation);
            $form->location($loc);
            $form->meta("action","save_verse");

            $template = new template("biblemodule","_form_editverse",$loc);
            $template->assign("form_html",$form->toHTML());
            $template->output();
        }
    }


?>